This document provides information about compiling IDL files.
Table of Contents
-------------------------
• Installing ToolServer and SOM
• Compiling IDL Files (CodeWarrior IDE)
• Compiling IDL Files (MPW)
• Compiling
• Common Problems
IMPORTANT: this document assumes you have already followed the MPW and/or CodeWarrior Installation Guide.
Installing ToolServer and SOM
To compile IDL files, you need to use the SOM compiler. SOM currently only runs as an MPW or ToolServer tool and is part of the ETO #21 package. If you are using CodeWarrior then you should install ToolServer. ToolServer is available from ETO, MPW Pro and CodeWarrior Gold Reference.
CodeWarrior users should also have installed the “SOMobjects™ TS” plugin tool. This tool is located in the “Getting Started:CodeWarrior Development:CodeWarrior Additions:INTO CodeWarrior Plugins” folder, and needs to be placed in the “CodeWarrior Plugins : Compilers” folder in your CodeWarrior folder. If you followed the “Installation Guide” procedure for CodeWarrior this tool should already be installed.
Compiling IDL Files (CodeWarrior)
Once you’ve written an IDL file, add it to the CodeWarrior project. Compile it directly by selecting the file and pressing command-K or by selecting the file and choosing Compile from the Project menu. If the file compiles without errors, the SOM compiler will have generated three new files, ending with the extensions .xih, .xh, and .cpp. Add the .cpp file to your project. This is where you must implement your code.
If you ever need to change your .idl file, the SOM compiler is smart enough to modify your .cpp file in place. You don't have to worry about your code being deleted. In some cases it will create a new set of methods (for instance, if you rename your SOM class); other times it fixes prototypes for you, and even inserts comments telling you what it did. Sounds scary, but it works fine.
You may notice that you don't have to use ToolServer directly. The SOM plugin tool looks like a standard compiler to CodeWarrior, but in reality it sends AppleEvents to ToolServer to compile the .idl file. As far as CodeWarrior is concerned, the plugin tool is doing the compile. Eventually we plan to make the SOM compiler a true plugin, eliminating the need for ToolServer. However, since ToolServer is doing the compile and not CodeWarrior, it can’t read open windows which haven’t been saved to disk. Make sure to save your .idl file to disk before compiling it.
At the moment, the SOM plugin tool is not officially supported or tested. It seems to work for most people. If you have problems then you may need to remove the .idl file from the project window and use the Non-CodeWarrior approach below.
Compiling IDL Files (MPW)
Compiling IDL files requires that you use MPW and SOM. Both of these are available on ETO #21 and other development CDs.
Compiling
• Add your .idl file to the MacMake.bmk file (the "Makefile")
When you generated your part with PartMaker, it created the CodeWarrior project and an MPW makefile, called MacMake.bmk. The makefile lists all the output of the idl files, like so:
__ComponentSourcesFromIDL = ∂
"{_FWTargetDir}SOMPart.cpp" ∂
"{_FWTargetDir}SOMPart.xh" ∂
"{_FWTargetDir}SOMPart.xih"
__ComponentObjects = ∂
"{_FWObjDir}"SOMPart.cpp.o
You don't list the .idl file in the makefile, instead you list the output files. The Make tool will determine how to build those output files based on our default rules.
If your idl file was called MyInterface.idl, you will add the output files to those definitions like this:
You must have your part's folder in the same folder as ODF for this to work. This is required anyway because some ODF scripts have relative paths.
FWBuild will run somc to output your .cpp, .xh, and .xih files. At this point you can implement your extension. If you change your .idl file, you need to do this step over again (but only this step). When the SOM compiler writes your .cpp file it will not delete anything, so you don't need to worry about saving code. It rewrites, not replaces, the .cpp file. In some cases it will create a new set of methods (for instance, if you rename your SOM class); other times it fixes prototypes for you, and even inserts comments telling you what it did. Sounds scary, but it works fine.
Common Problems
You may get "include file not found" errors. This would mean that you are trying to #include other .idl files which are not found in the standard OpendDoc or ODF set. You will need to add the locations of those other .idl files to the makefile. For example, if you were building Cyberdog parts you would probably have to put the PublicIncludes folder in your CodeWarrior folder, and would need to change the include listing like this:
__IDLIncludeDirs = d
-I "HD:CodeWarrior:MacOS Support:Headers:PublicIncludes:" d